/**      
 * @file		simpleIO2.cpp
 * @description		Demonstrates reading and writing to a file.
 *			Utilizes fstream and iostream libraries.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <fstream>
#include <iostream>
using namespace std;

/**
 * @return zero if the application executes successfully
 */
int main() {
	ifstream inFile;
	ofstream outFile;

	inFile.open("io.dat"); 		// Full paths can be used (windows) "D:\\projects\\lectures\\io.dat"
	outFile.open("out.dat"); 	// the double backslach is an escape character for the 
					// backslash
	
	int tempInt;
	for (int i = 0; i < 15; i++) {
		inFile >> tempInt;
		outFile << tempInt << endl;
	}

	inFile.close();
	outFile.close();

	inFile.clear(); 		// inFile is an object that has state
					// I use clear to reset that state
	
	//I could define a new input stream, however, I'll reuse
	//the current object inFile instead
	//
	//ifstream inFile2;
	//
	cout << "out.dat now contains\n";
	inFile.open("out.dat");
	for (int i = 0; i < 15; i++) {
		inFile >> tempInt;
		cout << "out.dat: " << tempInt << endl;
	}
	inFile.close();
	return 0;
}

